<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/11
 * Time: 15:20
 */

namespace App\Http\Controllers\MiniProgram;

use App\Http\Logics\MiniProgram\VipLogic;
use App\Http\Traits\VipTrait;
use App\Http\Controllers\BaseController;
class VipController extends BaseController
{
    use VipTrait;

    /**
     * @SWG\Post(
     *     path="/vip/create",
     *     tags={"Vip"},
     *     description="创建VIP，重复购买VIP(8100)",
     *     operationId="createVip",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(这里还用于获取user_id)",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_id",
     *         in="query",
     *         description="会员卡ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createVip()
    {
        $loginSession = $this->loginSession;
        $vip_card_id = $this->vip_card_id;
        $data = [
            'loginSession' => $loginSession,
            'vip_card_id' => $vip_card_id
        ];
        $response = VipLogic::createVip($data);
        errorLog($response);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vip/list",
     *     tags={"Vip"},
     *     description="获取会员列表",
     *     operationId="getVipList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = VipLogic::getVipList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}